<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <link rel="stylesheet" href="./index.css"/>

</head>

<body>
<button id ="btn">点击测试</button>
<!--如何head头部，此时的body对象会为null-->
<!--<script th:src="@{/ts/index.js}" type="text/javascript"></script>-->
<script>
    function createXMLHttpRequest(){
        var xmlHttp;
        try{
            xmlHttp = new XMLHttpRequest();
        } catch (e) {
         
            try {
                xmlHttp = new ActiveXObject("Msxml2.XMLHTTP");
            } catch (e) {
         
                try{
                    xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
                } catch (e){}
            }
        }            
        return xmlHttp;
        
    };
    var xmlHttp=createXMLHttpRequest();
    xmlHttp.open("POST","/index",true);
    xmlHttp.send("{'id':5,'name':'jack'}");
    xmlHttp.onreadystatechange=function(){
        if(xmlHttp.readyState==4){
            console.log(xmlHttp.responseText);
        }
    }
</script>
</body>

</html>